//
//  MenuViewController.m
//  Family
//
//  Created by 王声䘵 on 2018/4/21.
//  Copyright © 2018年 王声䘵. All rights reserved.
//

#import "MenuViewController.h"
#import "ViewController.h"
#import "MyNavigationController.h"
#import "FindNameViewController.h"
#import "UserViewController.h"
#import "loginViewController.h"
#import "Singleton.h"
@interface MenuViewController ()
@property(nonatomic,strong)NSArray *titleArr;
@property(nonatomic,strong)NSArray *imgArr;
//@property(nonatomic,strong)UIView *top;
//@property(nonatomic,strong)UIView *down;
@property(nonatomic) int flag;
@property(nonatomic,strong)UIButton *buttn1;
@property(nonatomic,strong)UIButton *downMenu;
@property (weak, nonatomic) IBOutlet UIImageView *backGroundImage;


@end

@implementation MenuViewController

-(void)viewWillAppear:(BOOL)animated
{
    _flag=0;
    //添加背景图片
    [_backGroundImage setImage:[UIImage imageNamed:@"背景叠加柔光"]];
    //下拉滚动界面
//    UIScrollView *scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 20, SCREEN_SIZE.width-20, SCREEN_SIZE.height)];
//
//    scroll.contentSize = CGSizeMake(SCREEN_SIZE.width-20, SCREEN_SIZE.height*2);
//    scroll.userInteractionEnabled = YES;
//    scroll.showsVerticalScrollIndicator = NO;
    //姓氏图片加载
//    for (int i = 0; i <= 15; i++) {
//        NSString *picName = [NSString stringWithFormat:@"%d.jpeg",i+1];
//        UIImage *image = [UIImage imageNamed:picName];
//        UIImageView *view = [[UIImageView alloc]initWithImage:image];
//        view.frame = CGRectMake(i%3*SCREEN_SIZE.width/3, i/3*SCREEN_SIZE.height/3+20, SCREEN_SIZE.width/3-20, SCREEN_SIZE.height/3-40);
//        [scroll addSubview:view];
//
//        view.userInteractionEnabled = YES;
//        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click:)];
//        tap.numberOfTapsRequired = 1;
//        tap.numberOfTouchesRequired = 1;
//        [view addGestureRecognizer:tap];
//    }
    
//    self.down.backgroundColor=[UIColor grayColor];
//    [self.down addSubview:scroll];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //隐藏导航栏
    self.navigationController.navigationBar.hidden=YES;
    //导航栏取消隐藏
//    if(self.navigationController.navigationBar.isHidden==YES)
//    {
//
//        [self.navigationController setNavigationBarHidden:NO];
//    }
//    else{
//
//    }
    
    self.titleArr = @[@"消失的姓氏",@"不为人知的姓氏",@"复姓",@"人数最多的姓氏",];
    self.imgArr = @[@"消失的姓氏",@"不为人知的姓氏",@"复姓",@"人数最多的姓氏",];
    //flag是判断上下界面的动画
    //_flag=1;
    //左返回键按钮
//    UIBarButtonItem *leftbut=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(LeftBack)];
//    self.navigationItem.leftBarButtonItem=leftbut;
    //右按钮
  //  UIImage *rightImage=[[UIImage imageNamed:@"userImage"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //barbutten会默认一个蓝色背景，UIImageRenderingModeAlwaysOriginal这个属性可以把背景修改为图片源背景
//
//    UIBarButtonItem *rightButten;
//    rightButten=[[UIBarButtornItem alloc]initWithImage:rightImage style:UIBarButtonItemStylePlain target:self action:@selector(rightButtenClick:)];
//    self.navigationItem.rightBarButtonItem=rightButten;
//    //上下界面
//   _top=[[UIView alloc]initWithFrame:CGRectMake(0, -140, MAINWINDOWWIDTH, 100)];//y=60
//
//    _top.backgroundColor=[UIColor cyanColor];
//    _down=[[UIView alloc]initWithFrame:CGRectMake(0, MAINWINDOWHEIGHT+120, MAINWINDOWWIDTH, MAINWINDOWHEIGHT-120)];//y=160
//    [self.view addSubview:_down];
//    [self.view addSubview:_top];
    
    // Do any additional setup after loading the view.
}
//右按钮点击事件
-(void)rightButtenClick:(UIButton *)but
{
    //单例类接受Username的值
    Singleton *UserName=[Singleton create];
    //判断用户是否登录
    if(UserName.UserName!=nil)
    {
    UIStoryboard *stroyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UserViewController *userView=[stroyboard instantiateViewControllerWithIdentifier:@"userView"];
    [self.navigationController pushViewController:userView animated:YES];
    }
    else{
        UIStoryboard *stroyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UserViewController *loginView=[stroyboard instantiateViewControllerWithIdentifier:@"login"];
        [self.navigationController pushViewController:loginView animated:YES];
    }
}
//上下合的界面
//- (IBAction)FirstViewTap:(id)sender {
//
//    [UIView animateWithDuration:0.5 animations:^{
//        CGRect frame=self.top.frame;
//        CGRect frameDown=self.down.frame;
//        frameDown.origin.y+=(MAINWINDOWHEIGHT)*(-_flag);
//        frame.origin.y+=160*_flag;
//        _flag=-1;
//        self.down.frame=frameDown;
//        self.top.frame=frame;
//    }];
//    if(self.navigationController.navigationBar.isHidden==YES)
//    {
//
//    }
//    else{
//        self.navigationController.navigationBar.hidden=YES;
//    }
//
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)Back:(id)sender {
     [self.navigationController popToRootViewControllerAnimated:YES];
}
- (IBAction)zhong:(id)sender {
   if(_flag==0)
   {
       _flag=1;
    UIStoryboard *stroyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    FindNameViewController *findName=[stroyboard instantiateViewControllerWithIdentifier:@"findImage"];
    
    [self.navigationController pushViewController:findName animated:NO];
   }
   else{
   
   }
}

- (IBAction)yinxing:(id)sender {
    if(_flag==0)
    {
         _flag=1;
    UIStoryboard *stroyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    FindNameViewController *findName=[stroyboard instantiateViewControllerWithIdentifier:@"findImage"];
    
        [self.navigationController pushViewController:findName animated:NO];}
    else
    {
        
    }
}
- (IBAction)shixing:(id)sender {
    if(_flag==0)
    {
         _flag=1;
    UIStoryboard *stroyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    FindNameViewController *findName=[stroyboard instantiateViewControllerWithIdentifier:@"findImage"];
    
    [self.navigationController pushViewController:findName animated:NO];
    }
    else{
        
    }
}
- (IBAction)fuxing:(id)sender {
    if (_flag==0) {
         _flag=1;
    UIStoryboard *stroyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    FindNameViewController *findName=[stroyboard instantiateViewControllerWithIdentifier:@"findImage"];
    
    [self.navigationController pushViewController:findName animated:NO];
    }
    else
    {
        
    }
}
//返回主界面
//- (IBAction)back:(id)sender {
//    NSLog(@"back");
//   [self.navigationController popToRootViewControllerAnimated:YES];
//}
//返回到分类界面
//-(void)Back:(UIButton *)butn{
//    [UIView animateWithDuration:0.5 animations:^{
//        CGRect frame=self.top.frame;
//        CGRect frameDown=self.down.frame;
//        frameDown.origin.y+=(MAINWINDOWHEIGHT)*(-_flag);
//        frame.origin.y+=160*_flag;
//
//        _flag=1;
//        self.down.frame=frameDown;
//        self.top.frame=frame;
//    }];
//    if(self.navigationController.navigationBar.isHidden==YES)
//    {
//        self.navigationController.navigationBar.hidden=NO;
//    }
//    else{
//
//    }
//}
//-(void)Click:(UIButton *)butn
//{
//
//
//    butn.backgroundColor=[UIColor grayColor];
//
//
//}
//-(void)ClickTwo:(UIButton *)butn
//{
//    butn.backgroundColor=[UIColor cyanColor];
//
//}
//左按钮点击事件
//-(void)LeftBack
//{
//
//    if(self.navigationController.navigationBar.isHidden==YES)
//    {
//
//    }
//    else{
//          [self.navigationController setNavigationBarHidden:YES];
//    }
//    [self.navigationController popToRootViewControllerAnimated:YES];
//
//}
//姓氏图片点击事件
//-(void)click:(UITapGestureRecognizer *)tap
//{
//    UIImageView *image=(UIImageView *)tap.view;
//    UIStoryboard *stroyboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
//    FindNameViewController *findName=[stroyboard instantiateViewControllerWithIdentifier:@"findImage"];
//    findName.findImage=image.image;
//    [self.navigationController pushViewController:findName animated:NO];
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
